package cm.unit3.theme4;

import cm.commom.ListNode;

public class ReverseList {
    public ListNode ReverseList(ListNode head) {
        if(head==null || head.next==null){
            return head;
        }

        ListNode pre = null;
        ListNode cur = head;
        ListNode next = head.next;

        while(cur!=null){
            cur.next = pre;
            pre = cur;
            cur = next;
            if(next!=null)
                next = next.next;
        }
        return pre;
    }
}
